// 引入pinia创建方法createPinia
// https://pinia.vuejs.org/
import { createPinia } from 'pinia'

// 引入pinia持久化存储插件
// https://www.npmjs.com/package/pinia-plugin-persistedstate
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

// 创建pinia
const pinia = createPinia()
// 持久化pinia
pinia.use(piniaPluginPersistedstate)

export default pinia

/*
import { defineStore } from 'pinia'

export const useLayoutStore = defineStore('index', {
  state: () => ({
  }),
  actions: {
  }
})

/!*
页面使用:
import { useLayoutStore } from '@/store/index'
import { storeToRefs } from 'pinia'

const store = useLayoutStore()

// 结构赋值需要storeToRefs api包裹为响应式
const { counter } = storeToRefs(store)
// 取值
counter.value

// 读取state数据
store.counter

// 修改state数据
store.$patch({
    counter: 7
})

// 调用actions方法
store.reset()

// 读取getters计算属性
store.doubleCount
*!/
*/
